import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Vuex from "vuex";
import axios from "axios";
import Antd from "ant-design-vue";
import { FormModel } from "ant-design-vue";
import common from "@/assets/js/common";
import VueLazyload from "vue-lazyload";
import apiAxios from "@/assets/js/request.js";
import vcolorpicker from "vcolorpicker";
import directive from "./directive"; // directive
import "./qiankun";
import "babel-polyfill";
// 引入echarts
import echarts from "echarts";
//图片点击放大
import VueDirectiveImagePreviewer from "vue-directive-image-previewer";
import dataV from "@jiaminghi/data-view";

import "viewerjs/dist/viewer.css";
import Viewer from "v-viewer";
import vant from 'vant';
import 'vant/lib/index.css';

import "ant-design-vue/dist/antd.css";
// import 'vue-directive-image-previewer/dist/assets/style.css'
// import 'devextreme/dist/css/dx.common.css';
// import 'devextreme/dist/css/dx.light.css';
// import MapFn from './plugs/ol'
// MapFn()
import "@/assets/css/global.less";
Vue.use(directive);
Vue.use(Viewer);
Vue.use(FormModel);
Vue.use(dataV);

// swiper
// import VueAwesomeSwiper from 'vue-awesome-swiper'
// import 'swiper/dist/css/swiper.css'
// Vue.use(VueAwesomeSwiper)
// import "swiper/dist/css/swiper.min.css";
// import "swiper/dist/js/swiper.min.js";
import "swiper/dist/css/swiper.css";

// import vgl from 'vue-golden-layout'
// Vue.use(vgl);
// import 'golden-layout/src/css/goldenlayout-light-theme.css'
// 引入公共样式
import "@/assets/global.css";

router.beforeEach((to, from, next) => {
  if (to.path == "/baoxin") {
    localStorage.removeItem("token");
    localStorage.removeItem("refreshToken");
    next();
  } else {
    if (localStorage.token) {
      // if(to.path=='/home/dashbord' && from.path.indexOf('/qiankunchild')!=-1){
      //   window.location.href ="/home/dashbord"
      //   // window.history.pushState(null,'','/home/dashbord')
      // }else{
      //   next()
      // }
      next();
    } else {
      if (to.path == "/login") {
        next();
      } else if (
        to.path == "/iamSso" ||
        to.path == "/home/imageStatistics/list" ||
        to.path == "/dingreport" ||
        to.path == "/dingscreen" ||
        to.path == "/" ||
        to.path == "/home/imageStatistics/organizationAnalyse" ||
        to.path == "/home/imageStatistics/processAnalyse" ||
        to.path == "/billboards" ||
        to.path == "/billboards2" ||
        to.path == "/processAnalyse" ||
        to.path == "/organizationAnalyse"
      ) {
        next();
      } else if (
        [
          "/demo",
          "/screen",
          "/screenSecond",
          "/screenThird",
          "/screenFourth",
          "/screen1",
          "/screenTest",
          "/screen2",
          "/screen3",
          "/screen4",
          "/info",
          "/tab",
        ].includes(to.path)
      ) {
        // 大屏开发 一级---四级
        document.title = `“智隼”安全生产风险管控系统`;
        next();
      } else if (["/manage", "/tables"].includes(to.path)) {
        document.title = `“智隼”管理系统`;
        // 后台管理页面
        next();
      } else if (["/home", "/port", "/onePort", "/oneType", "/work", "/real"]) {
        next();
      } else {
        next({ path: "/login" });
      }
    }
  }
});
import moment from "moment";
import { format } from "ol/coordinate";

Vue.prototype.$moment = moment;

import Loading from "@/components/Process/Loading";
Vue.use(Loading);

Vue.use(VueDirectiveImagePreviewer);

Vue.prototype.$echarts = echarts;

Vue.config.productionTip = false;

Vue.use(Vuex);
//没什么好解释的
Vue.use(Antd);
//ant.design框架组件
Vue.prototype.$ajax = axios;
//axios异步请求
Vue.use(common);
//公共变量
Vue.use(apiAxios);
//封装axios请求方法
Vue.use(VueLazyload);
//导出
//颜色选择器
Vue.use(vcolorpicker);
Vue.use(vant);

// import WorkDetailDialog from '@/components/Process/WorkDetailDialog';
// Vue.use(WorkDetailDialog);

new Vue({
  router,
  store,
  axios,
  render: (h) => h(App),
  beforeCreate() {
    Vue.prototype.$bus = this; //安装全局事件总线
  },
}).$mount("#app");
